package com.example.poi.service;

import java.util.List;
import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.example.poi.entity.Student;
import com.example.poi.repository.StudentRepository;

@Service
public class StudentService {

	@Autowired
	private StudentRepository studentRepository;
	
	public Student findById(Integer id) {
		Optional<Student> optional = studentRepository.findById(id);
		if(optional.isPresent()) {
			optional.get();
		}
		return null;
	}
	
	public List<Student> findAll(){
		return studentRepository.findAll();
	}

	public List<Student> findByTbClassId(Integer id) {
		return studentRepository.findByTbClassId(id);
		
	}
}
